//package com.spider.im.chat.message;
//
//import com.google.protobuf.Message;
//import com.spider.im.chat.proto.ChatProto;
//import org.reflections.Reflections;
//
//import java.util.Set;
//
//public class AnnotationModuleLoader {
//
//    public static void loadHandlers(String basePackage, HandlerRegistry registry) throws Exception {
//        Reflections reflections = new Reflections(basePackage);
//        Set<Class<?>> classes = reflections.getTypesAnnotatedWith(MessageTypeHandler.class);
//
//        for (Class<?> clazz : classes) {
//            if (!TypedMessageRegistry.class.isAssignableFrom(clazz)) continue;
//
//            MessageTypeHandler annotation = clazz.getAnnotation(MessageTypeHandler.class);
//            ChatProto.MessageType type = annotation.type();
//
//            @SuppressWarnings("unchecked")
//            TypedMessageRegistry<? extends Message> handler =
//                    (TypedMessageRegistry<? extends Message>) clazz.getDeclaredConstructor().newInstance();
//
//            registry.register(type, handler.toAdapter());
//        }
//    }
//}
